/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import { ReportViewProps, } from "../../common/base";
import {末尾链接, 落款单位地址,} from "../../common/rarelyVary";
import {检验结论报告,} from "./repView";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {ReportFirstPageHeadAllNmbbm, 目录页PL, 首页设备概况IndJj,} from "../../industrial/rarelyVary";
import {useItemsMapPressure} from "../../common/pressure";
import {PipeLineDiagram} from "../../industrial/viewLineDg";
import {Projects默认} from "./Regular.O-1";
import {注意事项GasC, } from "../../gas/rarelyVary";
import {PipelineCharacteristPrf} from "../../gas/viewFeature";
import {JobResponsibiliVw} from "./JobResponsibili";
import {ProblemHandleVw} from "./ProblemHandle";
import {SiteConstructVw} from "./SiteConstruct";
import {NonDestructiveVw} from "./NonDestructive";
import {WeldingQualifVw} from "./WeldingQualif";
import {QualityAssureVw} from "../QualityAssure";
import {检验结论GasC} from "../viewRes";
import {CertificatePage} from "./CertificatePage";


export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
  const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [rootMenu]=useRepMenuDirItems(Projects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
  return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
            { orc?.检验结论==='合格' &&
                <CertificatePage orc={orc} rep={rep}/>
            }
            {orc?.检验结论==='合格' && mapFxian.get('管道特性表')?.do &&
                <PipelineCharacteristPrf orc={orc} rep={rep}/>
            }
            {/*正式报告开始*/}
          <div css={{
              display: 'flex',
              flexDirection: 'column',
              justifyContent: 'space-between',
              "@media print": {
                    height:'100vh',       //一张纸的高度！同时配合 pageBreakAfter: 'always', 来约束特定纸张大小；
                    pageBreakInside: 'avoid',
              }
          }}>
                {ReportFirstPageHeadAllNmbbm({theme, rep, mbbm: 'FJB/TM-1007-1-0-2022',nMa:true})}
                <div>
                    <Text variant="h3" css={{textAlign: 'center',
                        "@media (min-width:690px),print and (min-width:538px)": {fontSize: theme.fontSizes[6],}
                    }}>长输管道施工监督检验报告</Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h6" css={{textAlign: 'center',}}>（ FJB/DB-1042-0-2020 ）</Text>
                </div>
                <div>{首页设备概况IndJj({theme, orc, rep,ngddm:true})}</div>
                <div css={{textAlign: 'center', "@media print": {pageBreakInside: 'avoid'}}}>
                    {落款单位地址}
                </div>
           </div>       {/*第一页纸张的,前面必定新断开打印一页的,才能确保100vh盛满一张纸张的底部区域,保证内容不会大于100vh前提下的稳妥做法*/}

            {注意事项GasC({
                rep,
                comply: '书为依据TSG D7006-2020《压力管道监督检验规则》制定，适用于长输管道施工监督检验报告的结论报告'
            })}

            {目录页PL({theme, orc, rep})}
            {检验结论报告({theme, orc, rep})}
            {检验结论GasC({theme, orc, rep, bcap:'监检'})}

            {mapFxian.get('受检单位基本情况及现场施工')?.do && <SiteConstructVw orc={orc} rep={rep}/>}
            {mapFxian.get('焊接作业人员资格')?.do && <WeldingQualifVw orc={orc} rep={rep}/>}
            {mapFxian.get('无损检测人员资格明细表')?.do &&
                <NonDestructiveVw orc={orc} rep={rep} title='无损检测人员资格明细表'/>
            }
            {mapFxian.get('监检工作内容和检验结果报告')?.do &&
                <JobResponsibiliVw orc={orc} rep={rep}/>
            }
            {mapFxian.get('发现问题的处理')?.do &&
                <ProblemHandleVw orc={orc} rep={rep}/>
            }
            {mapFxian.get('施工单位质量保证体系')?.do &&
                <QualityAssureVw orc={orc} rep={rep} title={'长输管道施工单位质量保证体系实施状况评价报告'}/>
            }

            {orc?.检验结论!=='合格' && mapFxian.get('管道特性表')?.do &&
                <PipelineCharacteristPrf orc={orc} rep={rep}/>
            }
            {mapFxian.get('管道单线图')?.do &&
                <PipeLineDiagram orc={orc} rep={rep} title={'管道单线图'}/>
            }
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
